<%@include file="/pages/include/tag_include.jsp"%>	
<%@include file="/pages/include/base_context.jsp"%>  

<script>
    jQuery(document).ready(function($){
        
        $('#add-section').click(function(){
            //var lastRow = $( '#table-section tr:last' );
            //var rowSeq = (lastRow.attr('row-id') == undefined) ? 0 : lastRow.attr('row-id') +1 ;
            $('#the-form').attr('action','<s:url value="/setup/review/add_section.do" />')
            $('#the-form').submit();
            
            
           // console.log((lastRow.attr('row-id') == undefined) );
//            console.log($( '#table-section tr:last' ));
            
            //console.log($('#table-section').html());
            
        });
        
    });
    
    
</script>
<div class="container">
    <%@include file="/pages/include/message_display_include.jsp"%> 
    
    <h4><s:text name="review_template_maintenance" /></h4>
    <form id="the-form" class="form-horizontal" method="POST" action='<s:url value="/setup/review/save.do"/>'>
        <div class="control-group">
            <label class="control-label" for="inputCode"><s:text name="code" /></label>
            <div class="controls">
                <input type="text" name="form.reviewTemplate.code" value='<s:property value="%{form.reviewTemplate.code}"/>' id="inputCode" placeholder="Code">
            </div>
        </div>

        <div class="control-group">
            <label class="control-label" for="inputDescription"><s:text name="description" /></label>
            <div class="controls">
                <input type="text" name="form.reviewTemplate.description" value='<s:property value="%{form.reviewTemplate.description}"/>' id="inputDescription" placeholder="Description">
            </div>
        </div>

        <div class="control-group">
            <a id="add-section" href="javascript:void(0);" class="btn btn-info pull-right">Add</a>
            <table id="table-section" class="table table-striped">
                <thead>
                    <th><s:text name="type" /></th>
                    <th><s:text name="content" /></th>
                    <th><s:text name="total_weight" /></th>
                    <th><s:text name="sequence_number_abbr" /></th>
                    <th>&nbsp;</th>
                </thead>
                <s:iterator value="form.reviewTemplate.templateSection" var="item" status="row">
                    <tr>
                        <td>
                            <input type="text" name="form.reviewTemplate.templateSection[<s:property value="#row.index" />].sectionType" value="<s:property value="#item.sectionType" />"></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td><input type="hidden" name="form.reviewTemplate.templateSection[<s:property value="#row.index" />].id" value="<s:property value="#item.id" />" ></td>
                    </tr>
                </s:iterator>
                
            </table>
            
        </div>    
            
            

        <a href="<s:url value="/setup/review/list.do"/>" class="btn btn-danger" ><s:text name="cancel"/></a>
        <input type="submit" value="<s:text name="save"/>" class="btn btn-success">    
    </form>
</div>
